<template>
  <div id="user_expand">
    <k-header headTitle="空间扩充" goBack="true"/>
    <div class="user_expand" :class="headIos?'side-fixd-ios':'side-fixed'">
      <div class="my_list">
        <ul>
          <li @click='spacePay(spacedatas.id, spacedatas.discountPrice)' v-for="spacedatas in spaceData" :key="spacedatas.id">
            <div class="me-left">
              <span>{{ spacedatas.goodsName }}</span>
              <!-- <span class="giving" style="margin: 0 0 0 1rem;color: #F89721;">赠2000份基础背调</span> -->
            </div>
            <div class="me_right">￥{{ spacedatas.discountPrice }}元</div>
          </li>
        </ul>
      </div>
    </div>
    <!-- <b-box ref="aaaa" content_title="是否余额支付$500.00" content_confirm="支付" content_cancel="取消"/> -->

    <div v-transfer-dom>
      <confirm v-model="show4" :close-on-confirm="false" confirm-text="确定" cancel-text="取消" @on-confirm="onConfirm">
        <p style="text-align:center;">{{ moneynum }}</p>
      </confirm>
      <confirm v-model="show5" :close-on-confirm="false" confirm-text="立即充值" cancel-text="取消" @on-confirm="onConfirms">
        <p style="text-align:center;">账户余额不足，请充值后使用</p>
      </confirm>
    </div>

    <!-- <div v-transfer-dom>
      <alert v-model="he" title="你好" content="神啊"></alert>
    </div> -->
    <toast v-model="showPositionValue" type="text" width="100%" :time="1800" is-show-mask text="购买成功" position="bottom"></toast>
  </div>

  <!-- 支付成功提示 -->

</template>

<script>
  import kHeader from '../common/head'
  import bBox from '../common/boxconfirm'
  import { Confirm, TransferDomDirective as TransferDom, Alert, Toast } from 'vux'
  import util from '../../libs/util'
  export default {
    name: 'expand',
    directives: {
      TransferDom
    },
    data() {
      return {
        spaceData: '',
        show4: false,
        show5: false,
        purchId: '',
        moneynum: '',
        moneynums: '',
        he: false,
        headIos: false,
        showPositionValue: false,
        isClick:true
      }
    },
    components: {
      kHeader,
      bBox,
      Confirm,
      Alert,
      Toast
    },
    methods: {
      getdatas() {
        let that = this;
        let url = 'lblsapp-h5/v2/personCenter/orderIndex.json';
        util.ajax.post(url).then(function(stats) {
          console.log(stats.data.res.data);
          that.spaceData = stats.data.res.data;
        }).catch(function(error){
          console.log(error);
        })
      },
      spacePay(k,h) {
        this.show4 = true;
        console.log(h);
        this.purchId = k;
        this.moneynum = '是否余额支付￥'+h+'元';
      },
      onConfirm() {
        if(this.isClick){
          this.isClick = false;
          console.log(123);
          let dats = {};
          let that = this;
          dats.goodsId = this.purchId;
          let drl = 'lblsapp-h5/v2/personCenter/buyStorageNumber.json';
          util.ajax.post(drl,dats).then(function(stats){
            if(stats.data.code == '0'){
              that.show4 = false;
              that.showPositionValue = true;
              that.isClick = true;
            }else if(stats.data.code == '1'){
              that.moneynums = stats.data.res.msg
              that.show5 = true;
            }
          }).catch(function(error){
            console.log(error);
          })
        }else {
          return false
        }

      },
      onConfirms() {
        this.show5 = false;
        this.$router.push('/userRecharge');
      }
    },
    created() {
      if (window.navigator.userAgent.indexOf('LBLSIOS') > -1) {
        this.headIos = true;
      }
      this.getdatas();
    }
  }
</script>
<style scoped>
  .user_expand {
    padding: 50px 0 0 0;
  }
  .side-fixd-ios {
    padding: 70px 0 0 0;
  }
  .my_list li {
    overflow: hidden;
    background-color: #fff;
    padding: 3px 0;
    margin: 5px 0 0 0;
    height: 40px;
    font-size: 1.4rem;
    color: #212121;
    border-bottom: 1px solid #e5e5e5;
  }

  .partic_list_time {
    font-size: 1.2rem;
    color: #808080;
  }

  .my_list li>div {}

  .me-left {
    float: left;
    width: 58%;
    height: 100%;
    line-height: 40px;
    padding: 0 0 0 1.5rem;
  }

  .me_right {
    float: right;
    height: 40px;
    line-height: 40px;
    text-align: right;
    padding: 0 1.5rem 0 0;
    color: #F89721;
  }
  .giving {
    margin: 0 0 0 1rem;
    color: #F89721;
    font-size: 1.2rem;
  }
</style>


